package com.bothin.experiment4.converter;

import com.bothin.experiment4.enums.ContactStatusEnum;
import com.bothin.experiment4.form.ContactForm;
import com.bothin.experiment4.model.Contact;
import org.springframework.util.StringUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by bothin
 * At 2019/12/18 23:04
 * Description:
 */
public class ContactForm2ContactConverter {

    public static Contact converter(ContactForm contactForm) throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = null;
        if (!StringUtils.isEmpty(contactForm.getCreateTime()))
            date = simpleDateFormat.parse(contactForm.getCreateTime());
        return new Contact(contactForm.getContactId(),contactForm.getCustomerId(),contactForm.getEmployeeId(),
                ContactStatusEnum.NOT_PERFORMANCE.getCode(),contactForm.getMoney(),date);
    }
}
